#include "include/redis.h"
#include "include/tcpService.h"
#include "include/ringBuffer.hpp"
#include <thread>

//cmake -B build; make -C build; ./build/cpp_study

int main(){
    std::thread t([]{
        std::cout << "Server is running..." << std::endl;
        TcpService::GetInstance().start();
        std::cout << "Server is stopped..." << std::endl;
    });

    Redis& redis = Redis::GetInstance();
    std::string command;
    int client_id;
    TcpService& tcpService = TcpService::GetInstance();

    while (true) {
        while (!tcpService.readCommand(command, client_id));
        tcpService.response(redis.command(command), client_id);
    }
    t.join();
    return 0;
}


    // redis.command("hgetall kfasef");
    // redis.command("hash key2 key1 hhhhh key2 kkkkk key3 lllll");
    // redis.command("hget key2 key3");
    // redis.command("hgetall key2");

    // redis.command("lpush rr redis dd");
    // redis.command("rpush rr aa bb");
    // redis.command("lrange rr 0 10");

    // redis.command("sadd set1 a d d d e f g h i j k l m n o p q r s t u v w x y z");
    // redis.command("smembers set1");

    // redis.command("set key1 value1");
    // redis.command("set key1 太厉害了！！");
    // redis.command("get key1");